package logic

import (
	"context"
	"shop-hub/models"

	"shop-hub/shoprpc/internal/svc"
	"shop-hub/shoprpc/shoprpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type GoodListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewGoodListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GoodListLogic {
	return &GoodListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 商品列表
func (l *GoodListLogic) GoodList(in *shoprpc.GoodListRequest) (*shoprpc.GoodListResponse, error) {
	// todo: add your logic here and delete this line

	var good models.Good

	var lists []*shoprpc.GoodList

	lists, err := good.GoogList(models.DB)
	if err != nil {
		return nil, err
	}

	return &shoprpc.GoodListResponse{
		List: lists,
	}, nil
}
